# 服务器返回HTML页面
# 1. 检查响应的状态码是否为401（未授权）或302（重定向）等。
# 2. 或者检查响应内容是否是HTML（通过检查响应头`Content-Type`是否为`text/html`）。
# 3. 或者检查响应文本中是否包含特定的字符串（例如“登录”）。


import pytest
import requests
from send.Send import Send
from utils.read_yaml import read_yaml


class Test_unauthorized:

    # 银行卡新增-接口越权测试
    # @pytest.mark.parametrize( "args" ,  read_yaml("D:/Projects/接口自动化/data/unauthorized.yaml")  )
    def test_a_bankcard_add(self):
        args = read_yaml("D:/Projects/接口自动化/data/unauthorized.yaml")
        test_bankcard_add = args[0]

        exp = args[0]["exp"]
        session  = requests.session()
        se = Send()

        result = se.send_bankcard_add(session, test_bankcard_add)
        #断言？如何判断返回登录页面
        # assert result["code"] == 200 and result["body"]["code"] == exp
        assert exp in result

    # 银行卡删除-接口越权测试
    def test_a_bankcard_delete(self):
        args = read_yaml("D:/Projects/接口自动化/data/unauthorized.yaml")
        test_bankcard_add = args[1]

        exp = args[1]["exp"]
        session  = requests.session()
        se = Send()

        result = se.send_bankcard_delete(session, test_bankcard_add)
        #断言？如何判断返回登录页面
        # assert result["code"] == 200 and result["body"]["code"] == exp
        assert exp in result

    # 银行卡修改-接口越权测试
    def test_a_bankcard_update(self):
        args = read_yaml("D:/Projects/接口自动化/data/unauthorized.yaml")
        test_bankcard_add = args[2]

        exp = args[2]["exp"]
        session  = requests.session()
        se = Send()

        result = se.send_bankcard_delete(session, test_bankcard_add)
        #断言？如何判断返回登录页面
        # assert result["code"] == 200 and result["body"]["code"] == exp
        assert exp in result

    # 买入零钱理财-接口越权测试
    def test_a_buy_change(self):
        args = read_yaml("D:/Projects/接口自动化/data/unauthorized.yaml")
        test_bankcard_add = args[3]

        exp = args[3]["exp"]
        session  = requests.session()
        se = Send()

        result = se.send_buy_change(session, test_bankcard_add)
        #断言？如何判断返回登录页面
        # assert result["code"] == 200 and result["body"]["code"] == exp
        assert exp in result

    #买入期限理财-接口越权测试
    def test_a_buy_termFinancal(self):
        args = read_yaml("D:/Projects/接口自动化/data/unauthorized.yaml")
        test_bankcard_add = args[4]

        exp = args[4]["exp"]
        session  = requests.session()
        se = Send()

        result = se.send_buy_termFinancal(session, test_bankcard_add)
        #断言？如何判断返回登录页面
        # assert result["code"] == 200 and result["body"]["code"] == exp
        assert exp in result

    # 买入基金理财-接口越权测试
    def test_a_buy_fundProduct(self):
        args = read_yaml("D:/Projects/接口自动化/data/unauthorized.yaml")
        test_bankcard_add = args[5]

        exp = args[5]["exp"]
        session  = requests.session()
        se = Send()

        result = se.send_buy_fundProduct(session, test_bankcard_add)
        #断言？如何判断返回登录页面
        # assert result["code"] == 200 and result["body"]["code"] == exp
        assert exp in result

    # 申请网贷-接口越权测试
    def test_a_loan(self):
        args = read_yaml("D:/Projects/接口自动化/data/unauthorized.yaml")
        test_bankcard_add = args[6]

        exp = args[6]["exp"]
        session  = requests.session()
        se = Send()

        result = se.send_loan(session, test_bankcard_add)
        #断言？如何判断返回登录页面
        # assert result["code"] == 200 and result["body"]["code"] == exp
        assert exp in result

